package cn.cymym.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import cn.cymym.utils.ModelConvert;
import cn.cymym.utils.jdbcUtil;

public class FistPageDaoImpl extends ModelConvert implements FistPageDao {

	@Override
	public List<Map<String, Object>> selectInfo() {
		// TODO 查询画的详细信息
		Connection connection  = jdbcUtil.getConnection();
		String sql = "SELECT p.*,a.name FROM proandartist pa JOIN  product p ON  pa.`product_id`=p.`id` \r\n" + 
				"JOIN artist a ON a.`id` = pa.`artist_id` WHERE p.`ispreferred` = 1 LIMIT 13";
		
		List<Map<String, Object>> list = null;
		try {
			PreparedStatement pStatement = connection.prepareStatement(sql);
			ResultSet resultSet = pStatement.executeQuery();
			list = convertList(resultSet);
			return list;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}
	
	}

}
